package activity;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.example.administrator.gongxiangcheng.R;
import com.flyco.tablayout.SlidingTabLayout;
import com.flyco.tablayout.listener.OnTabSelectListener;
import com.recker.flybanner.FlyBanner;

import java.util.ArrayList;
import java.util.List;

import fragment.XqFragment1;
import fragment.XqFragment2;
import fragment.XqFragment3;
import utils.ViewFindUtils;

/**
 * Created by Administrator on 2017/3/28.
 */

public class mineXqActivity extends AppCompatActivity implements OnTabSelectListener {

    private Context mContext = this;
    private FlyBanner flyBanner;
    private TextView textView;
    private ArrayList<Fragment> mFragments = new ArrayList<>();
    private final String[] mTitles = {
            "项目详情", "项目股东", "项目进度"
    };
    private MyPagerAdapter mAdapter;




    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.minexq_main);
        textView = (TextView) findViewById(R.id.w_y_r_g);

        /**
         * 加载本地图片
         */
        flyBanner = (FlyBanner) findViewById(R.id.banner_1);
        List<Integer> images = new ArrayList<>();
        images.add(R.drawable.a);
        images.add(R.drawable.b);
        images.add(R.drawable.c);
        images.add(R.drawable.d);
        images.add(R.drawable.b);
        flyBanner.setImages(images);

        flyBanner.setOnItemClickListener(new FlyBanner.OnItemClickListener() {
            @Override
            public void onItemClick(int position) {


            }
        });

       textView.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View v) {




           }
       });

      /*  bnp = (NumberProgressBar)findViewById(R.id.numberbar1);
        bnp.setProgress(50);*/
        mFragments.add(new XqFragment1());
        mFragments.add(new XqFragment2());
        mFragments.add(new XqFragment3());
        View decorView = getWindow().getDecorView();
        ViewPager vp = ViewFindUtils.find(decorView, R.id.vp);
        vp.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                return true;
            }
        });
        mAdapter = new MyPagerAdapter(getSupportFragmentManager());
        vp.setAdapter(mAdapter);
        final SlidingTabLayout tabLayout_7 = ViewFindUtils.find(decorView, R.id.tl_7);
        tabLayout_7.setViewPager(vp, mTitles);
    }



    public void onTabSelect(int position) {
        Toast.makeText(mContext, "onTabSelect&position--->" + position, Toast.LENGTH_SHORT).show();
    }


    public void onTabReselect(int position) {
        Toast.makeText(mContext, "onTabReselect&position--->" + position, Toast.LENGTH_SHORT).show();
    }

    private class MyPagerAdapter extends FragmentPagerAdapter {
        public MyPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public int getCount() {
            return mFragments.size();
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return mTitles[position];
        }

        @Override
        public Fragment getItem(int position) {
            return mFragments.get(position);
        }
    }

}
